package com.eight.uploud.controller;

import com.eight.common.pojo.EduCourse;
import com.eight.common.pojo.EduTeacher;
import com.eight.common.pojo.TbMember;

import com.eight.common.vo.Result;
import com.eight.uploud.service.EduTeacherService;
import com.eight.uploud.service.TbMemBerService;
import com.eight.uploud.vo.ShouCangVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: qy8-education
 * @description:
 * @author: 平家祥
 * @create: 2023-06-02 16:56
 **/
@RestController
@RequestMapping("/tcore/teacher")
@Api("讲师招募、个人中心等")
public class EduTeacherController {


    @Autowired
    EduTeacherService service;
    @ApiOperation("讲师招募")
    @PostMapping("/qianaddTeacher")
    public Result qianaddTeacher(@RequestBody EduTeacher eduTeacher){
        Result insert = service.insert(eduTeacher);
        return Result.success(insert);
    }

    @Autowired
    TbMemBerService tbMemBerService;
    @ApiOperation("个人中心")
    @GetMapping("/findStudentBymobile/{mobile}")
    public Result findStudentByMobile(@PathVariable String mobile){
        TbMember tbMember = tbMemBerService.selectOneByMobile(mobile);
        return Result.success(tbMember);
    }
    @ApiOperation("修改信息")
    @PostMapping("/modifyStudentInformation")
    public Result modifyStudentInformation(@RequestBody TbMember tbMember){
        tbMemBerService.updateByMobile(tbMember);
        return Result.success();
    }

    @ApiOperation("我得收藏")
    @PostMapping("findFavoriteCourseById/{HuiYuanId}")
    public Result findFavoriteCourseById(@PathVariable String HuiYuanId){
        List<EduCourse> eduCourses = tbMemBerService.findByHuiYuanId(HuiYuanId);
        return Result.success(eduCourses);
    }
    @ApiOperation("取消收藏")
    @PostMapping("/deleteFavoriteCourse")
    public Result deleteFavoriteCourse(@RequestBody ShouCangVo shouCangVo){
        Integer integer = tbMemBerService.deleteFavoriteCourse(shouCangVo);
        if (integer>0){
            return Result.success();
        }
        return Result.fail();

    }


}
